// import { createRouter, createWebHashHistory } from 'vue-router';
import { createRouter, createWebHistory } from 'vue-router';

import Home from '@/views/Home.vue';
//主要用来拦截是否登录过
// import { getToken } from '@/utils/auth'
// 用来记录登录logo 页面的路由 从了哪里来，好router back 还是 go home

const routes = [
  {
    path: '/',
    redirect: '/home',
    hide: true
  },
  {
    path: '/home',
    name: '首页',
    component: Home,
    meta: { icon: '#icon1', title: '首页', enName: 'Home Page' }
  },
  // {
  //   path: '/teachingresearch',
  //   name: '教学科研',
  //   redirect: '/teachingresearch/teachingadministration',
  //   component: () => import('../views/TeachingResearch.vue'), //教学科研
  //   meta: { icon: '#icon1', title: '教学科研', enName: 'Teaching Research' },
  //   beforeEnter: (to, from, next) => {
  //     // console.log(to,from)
  //     if (getToken('ust')) {
  //       next()
  //     } else {
  //       next('/logon')
  //     }
  //   },
  //   children: [
  //     {
  //       path: 'departmentoverview',
  //       name: '部门概况',
  //       hide: true,
  //       component: () =>
  //         import('@/views/TeachingResearchChilds/DepartmentOverview.vue'),
  //       meta: {
  //         icon: '#icon1',
  //         title: '部门概况',
  //         parentPath: '/teachingresearch',
  //       },
  //       // children: [
  //       //   {
  //       //     path: 'detail',
  //       //     name: '部门概况详情',
  //       //     hide: true,
  //       //     component: () =>
  //       //       import(
  //       //         '@/views/TeachingResearchChilds/DepartmentOverviewDetail.vue'
  //       //       ),
  //       //     meta: {
  //       //       icon: '#icon1',
  //       //       title: '部门概况详情',
  //       //       parentPath: '/teachingresearch/departmentoverview',
  //       //     },
  //       //   },
  //       // ],
  //     }

  //   ],
  // },
  {
    path: '/logon',
    name: 'logon',
    hide: true,
    component: () => import('../views/logon.vue') //登录
  },
  {
    path: '/scrollto',
    name: 'scrollto',
    hide: true,
    component: () => import('../views/scrolTo.vue') //
  },
  {
    path: '/test',
    name: 'test',
    component: () => import('../views/Test.vue') //
  },
  {
    path: '/suspense',
    name: 'Suspense',
    component: () => import('../views/Suspense.vue') //
  },
  {
    path: '/directive',
    name: 'directive',
    component: () => import('../views/Directive.vue') //
  },
  {
    path: '/watfull',
    name: 'watfull',
    component: () => import('../views/Watfull.vue') //
  },
  {
    path: '/webworks',
    name: 'webworks',
    component: () => import('../views/WebWorks.vue') //
  },
  {
    path: '/vmodel',
    name: 'vmodel',
    component: () => import('../views/VModel.vue') //测试数据绑定
  },
  {
    path: '/sendflie',
    name: 'sendflie',
    component: () => import('../views/SendFile.vue') //
  },
  {
    path: '/page',
    name: 'page',
    component: () => import('../views/Page.vue') //
  },
  {
    path: '/404',
    name: 'notFound',
    hide: true,
    component: () => import('../views/404.vue') //教学科研
  },
  {
    path: '/:pathMatch(.*)*',
    // name: '404',
    redirect: '/404',

    hide: true
    // component: () => import('../views/404.vue'),
  }
];

const router = createRouter({
  // history: createWebHashHistory(),
  history: createWebHistory(),
  routes
});

// 全局守卫
// router.beforeEach((to, form, next) => {
//   console.log('to', to);
//   console.log('form', form);
//   next();
// });

export default router;
